package com.unicomcz.article;

import com.unicomcz.ActionBase;

public class ViewArticleAction extends ActionBase
{
    private String artId;
    private String artTitle;
    private String artContent;
    private String operTime;
    
    /**
     * @return the artId
     */
    public String getArtId()
    {
        return artId;
    }

    /**
     * @param artId the artId to set
     */
    public void setArtId(String artId)
    {
        this.artId = artId;
    }

    /**
     * @return the artTitle
     */
    public String getArtTitle()
    {
        return artTitle;
    }

    /**
     * @param artTitle the artTitle to set
     */
    public void setArtTitle(String artTitle)
    {
        this.artTitle = artTitle;
    }

    /**
     * @return the artContent
     */
    public String getArtContent()
    {
        return artContent;
    }

    /**
     * @param artContent the artContent to set
     */
    public void setArtContent(String artContent)
    {
        this.artContent = artContent;
    }

    /**
     * @return the operTime
     */
    public String getOperTime()
    {
        return operTime;
    }

    /**
     * @param operTime the operTime to set
     */
    public void setOperTime(String operTime)
    {
        this.operTime = operTime;
    }

    public String executeAction(){
        String sqlStr = "SELECT art_title,to_char(oper_time,'yyyy-mm-dd'),art_Content " + 
        		   " FROM dls_article where art_id=? and status=0";
        boolean dbFlag = setupConn("dls");
        if (!dbFlag) {
            log.debug(userInfo.getUserId()+"读取文件失败!因为建立数据库连接失败");
            return "fail";
        }
        String[] art = getSingle(sqlStr);
        if (art==null) {
            log.info(artId);
            addActionMessage("文章不存在！");
            return "fail";
        }
        artTitle=art[0];
        operTime=art[1];
        artContent = art[2];
        tearDown();
        return SUCCESS;
    }
    
   protected void regParam2single() {
        try {
            pstmt.setString(1, artId);
        }catch(Exception e) {
            log.info(e);
        }
    }
}
